import java.util.*;

public class Day1 {
    /**
     * 点击消除
     */
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] s = scanner.next().toCharArray();
        Stack<Character> stack = new Stack<>();
        for (char c : s) {
            if (stack.isEmpty() || c != stack.peek()) {
                stack.push(c);
            } else {
                stack.pop();
            }
        }
        if (stack.isEmpty()) {
            System.out.println("0");
        } else {
            Stack<Character> ret = new Stack<>();
            while (!stack.isEmpty()) {
                ret.push(stack.pop());
            }
            while (!ret.isEmpty()) {
                System.out.print(ret.pop());
            }
        }
    }

    /**
     * 数组交集
     */
    public ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        // write code here
        Set<Integer> set1 = new HashSet<>();
        for (int num : nums1) {
            set1.add(num);
        }

        Set<Integer> set2 = new HashSet<>();
        for (int num : nums2) {
            if (set1.contains(num)) {
                set2.add(num);
            }
        }

        ArrayList<Integer> ret = new ArrayList<>();
        for (int num : set2) {
            ret.add(num);
        }
        return ret;
    }


    /**
     * 数字统计
     * @param args
     */
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入两个数,确定范围:");
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int count = 0;
        for (int i = a; i <= b; i++) {
            int tmp = i;
            while (tmp != 0) {
                if (tmp % 10 == 2) {
                    count++;
                }
                tmp /= 10;
            }
        }
        System.out.println(count);
    }

    /**
     * 移除元素
     * @param nums
     * @param val
     * @return
     */
    public int removeElement(int[] nums, int val) {
        int n = nums.length;
        int slow = 0;
        for (int fast = 0; fast < n; fast++) {
            if (nums[fast] != val) {
                nums[slow++] = nums[fast];
            }
        }
        return slow;
    }
}
